package com.abocode.aichat.client;


import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author guanxf
 */
public class TcpClientFactory {
    private static volatile TcpClient tcpClient;

    public static TcpClient getLocalClient() {
        if (tcpClient == null) {
            try {
                tcpClient = new TcpClient(InetAddress.getLocalHost().getHostName(), 52222);
            } catch (UnknownHostException e) {
                e.printStackTrace();
            }
        }
        return tcpClient;
    }

    public static TcpClient getTcpClient(String domain, int port) {
        if (tcpClient == null) {
            tcpClient = new TcpClient(domain, port);
        }
        return tcpClient;
    }
}
